//
//  CAPTabbarController.swift
//  CAPSwift
//
//  Created by captain on 16/4/17.
//  Copyright © 2016年 captain. All rights reserved.
//

import UIKit

class CAPMainController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        // MARK: - 初始化tabBar
        let tabbar = CAPTabBar()
        
        tabbar.capDelegate = self
        
        //KVC
        setValue(tabbar, forKey: "tabBar")
        

        addChildViewController(CAPHomeTableController(), imgName:"tabbar_home" , title: "首页")
        
        addChildViewController(CAPMessageTableController(), imgName:"tabbar_message_center" , title: "消息")
        
        addChildViewController(CAPDiscoveryTableController(), imgName:"tabbar_discover" , title: "发现")
        
        addChildViewController(CAPProfileTableController(), imgName:"tabbar_profile" , title: "我的")
        
    
    
    
    
    }
    
    func addChildViewController(childController: UIViewController, imgName: String, title: String ) {
        
        childController.tabBarItem.image = UIImage(named: imgName)
        
        childController.tabBarItem.selectedImage = UIImage(named: "\(imgName)_selected")
        
        childController.title = title
        
        
        
        addChildViewController(UINavigationController(rootViewController: childController))
        
        
    }
}

// MARK: - 分类extension
extension CAPMainController: CAPTabBarDelegate{
    func composeButtonClick() {
        
    }
}
